package app.pages;

import java.io.File;

import org.vaadin.navigator7.NavigableApplication;
import org.vaadin.navigator7.Page;

import app.downloadupload.FileDownloadResource;
import app.webapplication.MyApplication;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.VerticalLayout;

@Page
public class MainPage extends VerticalLayout {

	public MainPage(){
		final Button button = new Button("Upload application button");
		this.addComponent(button);
		
		button.addListener(new ClickListener() {

			public void buttonClick(ClickEvent event) {

				Application myApp = (MyApplication)NavigableApplication.getCurrent();
				
				final String path = myApp.getContext().getBaseDirectory().getAbsolutePath();
				
				event.getButton().getWindow().open(new FileDownloadResource(
						new File(path+File.separatorChar+"VAADIN"+File.separatorChar+"export"+
								File.separatorChar+"dfddfdfdf.xml"), myApp));
				System.out.println(path+File.separatorChar+"VAADIN"+File.separatorChar+"export"+
						File.separatorChar+"dfddfdfdf.xml");

			}
		});
	}


}
